<template>
  <div class="profile-settings">
    <h2>系统预约概率设置</h2>

    <!-- 用户名修改表单 -->
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="概率">
        <el-input v-model="form.configValue"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="saveChanges">保存修改</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { setPassProbability, getPassProbability } from "@/api/reservation";
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      form: {},
    };
  },
  computed: {
    ...mapGetters(["uid"]),
  },
  created() {
    this.loadData();
  },
  methods: {
    async saveChanges() {
      const param = {
       passProbability: this.form.configValue,
      };
      const res = await setPassProbability(param);
      if (res.code == 200) {
        this.$message({
          message: "修改成功",
          type: "success",
        });
      } else {
        this.$message({
          message: "修改有误",
          type: "warning",
        });
      }
    },
    async loadData() {
      const res = await getPassProbability();

      if (res.code = 200) {
        this.form = res.data.probability;
        console.log(this.form);
      }
    },
  },
};
</script>

<style lang="scss" scoped>
/* 添加一些样式以美化页面 */
.profile-settings {
  max-width: 400px;
  
  padding: 20px;
}

.form-group {
  margin-bottom: 15px;
}

label {
  display: block;
  margin-bottom: 5px;
}
</style>
